<template>
  <div class="exam-box" @click="handleClick">
    <div class="category-container">{{ exam.type }}</div>
    <div class="exam-info">
      <div class="exam-title">{{ exam.title }}</div>
      <span class="status">
        截止日期: {{ exam.deadline }} | {{ status }}
      </span>
    </div>

    <!-- <el-button @click="goto" type="primary">去批阅</el-button> -->
  </div>
</template>

<script>
const numMapStatus = ["未完成", "已完成", "已完成"];
export default {
  name: "ExamBox",
  props: ["exam", "to"],
  computed: {
    status() {
      return numMapStatus[this.exam.status];
    },
  },
  methods: {
    handleClick() {
      console.log(this.to);
      // 要去哪儿 要带着什么去
      // when student's exam page, params => eid => 考试的id，拿着该id去请求考试的具体数据
      // 去的地方是：/examination
      // 当在教员的界面，带着的是eid，去的地方是/read-over
      // 
      const { exam_id } = this.exam;
      this.$router.push({
        path: this.to,
        query: {
          exam_id,
        },
      });
    },
  },
};
</script>

<style lang='less' scoped>
.exam-box {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  background-color: #fff;
  height: 70px;
  cursor: pointer;
  &:hover {
    background-color: #f7fafc;
  }
  .category-container {
    width: 42px;
    height: 42px;
    background-color: #c4c9cc;
    color: #fff;
    border-radius: 8px;
    text-align: center;
    line-height: 42px;
    margin-left: 20px;
  }
  .exam-info {
    width: 100%;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: flex-start;
    margin-left: 20px;
    .exam-title {
      line-height: 20px;
      font-size: 14px;
      font-weight: 400;
      color: #181e33;
      max-width: 92%;
    }
    .status {
      font-size: 12px;
      font-weight: 400;
      color: #a8a8b3;
      line-height: 17px;
      margin-top: 4px;
    }
  }
}
</style>